// ** Copyright (c) 2011* Freiburg, Germany * All rights reserved.
// ** File name：Term.cpp
// ** Current version：1.0 * Author：Yongkang Zhong * Finish time：22.05.2011
// ** Replace version：1.0 * Original author: Yongkang Zhong * Finish time：22.05.2011

#include "Number.h"

// The Function term gets the value of a term.
double term(char *str, int &index)
{
    double value = 0.0;
    
    value = number(str, index);
    
    while(true)
    {
        switch(str[index])
        {
            case '*':
                value *= number(str, ++index);
                break;
            case '/':
                value /= number(str, ++index);
                break;
            default:
                return value;
        }
    }
    
    return value;
}
